/*
 *	MainWindow.h
 *
 * 	Copyright (C) 2011 Aaron Huang
 * 	This file is part of StackPainter.
 *
 * 	StackPainter is free software: you can redistribute it and/or modify
 * 	it under the terms of the GNU General Public License as published by
 * 	the Free Software Foundation, either version 3 of the License, or
 * 	(at your option) any later version.
 *
 * 	StackPainter is distributed in the hope that it will be useful,
 * 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 * 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * 	GNU General Public License for more details.
 *
 * 	You should have received a copy of the GNU General Public License
 * 	along with StackPainter.  If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef MAINWINDOW_H_
#define MAINWINDOW_H_

#include <QMainWindow>
#include <QList>

class IncomeStatementCSVParser;
class CompanyInfo;
class QAction;
class QToolBar;
class QVBoxLayout;
class QHBoxLayout;
template <typename T>
	class LineChartWidget;
class QPushButton;
class QLabel;
class QLineEdit;

class MainWindow : public QMainWindow {
	Q_OBJECT

public:
	MainWindow();

	~MainWindow();

protected:
	void closeEvent(QCloseEvent *event);

private slots:
	void selectPath();

	void showNextCompany();

	void showPreviousCompany();

	void searchCompany();

private:
	/*
	 * Creates actions inside menu bar.
	 */
	void createActions();

	/*
	 * Creates tool bar.
	 */
	void createToolbar();

	/*
	 * Creates views.
	 */
	void createViews();

	/*
	 * Shows warning message.
	 */
	void showWarningMessage(QString message);

	void setCompanyLabel(const CompanyInfo* companyInfo);

	void refreshView();

	void setFunctionWidgetsEnable(bool isEnable);

	void clearCompanyInfos();

	QAction* _selectPathAct;
	QAction* _exitAct;

	// View related attributes.
	QVBoxLayout* _vLayout;
	QHBoxLayout* _hLayout;
	LineChartWidget<double>* _lineChartWidget;
	QToolBar* _toolbar;
	QPushButton* _nextButton;
	QPushButton* _previousButton;
	QLabel* _companyLabel;
	QLineEdit* _searchLineEdit;
	QPushButton* _searchButton;

	// Model related attributes.
	IncomeStatementCSVParser* _parser;
	QList<CompanyInfo*> _companyInfos;
	QList<CompanyInfo*>::ConstIterator _currentCompanyInfo;
};

#endif /* MAINWINDOW_H_ */
